#--------------------item家具类
class item:
    def __init__(self,name,area):
        """家具类

        Args:
            name (_type_): 家具名称
            area (_type_): 家具面积
        """
        self.name = name
        self.area = area
        
    def __str__(self):   #常用于直接打印对象，友好易于理解
        return "str家具名称:{}  家具面积:{}".format(self.name,self.area)
    def __repr__(self):  #用于打印list,set,dict等内部所有对象
        return "repr家具名称:{}  家具面积:{}".format(self.name,self.area)



#--------------------house房子类
class house:
    def __init__(self,addr,area):
        """房子类

        Args:
            name (_type_): 房子地址
            area (_type_): 房子面积
        """
        self.address = addr
        self.area = area
        #房子剩余面积
        self.free_area = area
        #房子家具列表
        self.items = []
        
    def add_item(self,item):
        if self.free_area>=item.area:
            self.items.append(item)
            self.free_area-=item.area
            print("添加成功，",item)
        else:
            print("房子面积不足")
        
        
    
    def __str__(self):
        return "房子地址:{} 房子占地面积:{}".format(self.address,self.area)



#-------------------主程序逻辑

item1 = item("沙发",10)
item2 = item("私人影院",95)
print(item1,item2)

house1 = house("金域华府",100)
print(house1)

house1.add_item(item1)
house1.add_item(item2)
print(house1,"家具个数：",len(house1.items))

print(house1.items)